package com.abss.vote.mapper;

import com.abss.vote.model.DistrictList;
import com.abss.vote.model.DistrictListUserWorkVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface DistrictListMapper {

    List<DistrictList> getCounty();
    List<DistrictList> getCountyById(int id);
    List<DistrictList> getCountyid(int id);
    List<DistrictList> getCountyidaa(@Param("id")int id,@Param("SERVER_ID")String SERVER_ID);
    List<DistrictListUserWorkVo> getCountyByIda(@Param("id")int id);
    List<DistrictListUserWorkVo> getCountyida(@Param("id")int id,@Param("SERVER_ID")String SERVER_ID);
    List<DistrictListUserWorkVo> getCountyByIdas(@Param("id")int id);
    String getCountyName(int DISTRICT_ID);

    List<DistrictListUserWorkVo> getAllCountry();

    @Select("select count(*) from DISTRICT_LIST where DISTRICT_NAME=#{district_name}")
    int checkDistrictName(@Param("district_name") String district_name);

    int addDistrictName(DistrictList districtList);
    int addDistrictNameAdmin(DistrictList districtList);

    @Delete("delete from DISTRICT_LIST where ID=#{id}")
    int deleteDistrict(@Param("id") Integer id);

    int updateDistrict(@Param("ID") Integer ID,@Param("district_name") String district_name,
            @Param("province") String province,
            @Param("city") String city,
            @Param("data_level") Integer data_level,
            @Param("school_id") String school_id);

    int updateDisplay(DistrictList dis);

    void updateDistrictParentName(@Param("id")Integer id,@Param("district_name") String district_name);

    String getServerId(@Param("district_id")Integer district_id);

    List<DistrictList> getCountyidab(@Param("id")int id,@Param("SERVER_ID")String SERVER_ID,@Param("ADMIN") String ADMIN);

    @Update("update DISTRICT_LIST set ADMIN=#{ADMIN} where ID=#{ID}")
    void updateDistrictAdmin(@Param("ID")Integer ID,@Param("ADMIN") String ADMIN);
}

